<?php if (!defined('THINK_PATH')) exit(); /*a:2:{s:92:"D:\phpStudy\PHPTutorial\WWW\xbs22\fly\public/../application/admin\view\admin_role\index.html";i:1542521763;s:72:"D:\phpStudy\PHPTutorial\WWW\xbs22\fly\application\admin\view\layout.html";i:1542336746;}*/ ?>
<!doctype html>
<html lang="en">
<head>
	<meta charset="UTF-8">
	<title>后台登录-X-admin2.0</title>
	<meta name="renderer" content="webkit|ie-comp|ie-stand">
	<meta http-equiv="X-UA-Compatible" content="IE=edge,chrome=1">
	<meta name="viewport" content="width=device-width,user-scalable=yes, minimum-scale=0.4, initial-scale=0.8,target-densitydpi=low-dpi" />
	<link rel="shortcut icon" href="/favicon.ico" type="image/x-icon" />
	<link rel="stylesheet" href="/static/admin/css/font.css">
	<link rel="stylesheet" href="/static/admin/css/xadmin.css">
	<script type="text/javascript" src="https://cdn.bootcss.com/jquery/3.2.1/jquery.min.js"></script>
	<script src="/static/admin/lib/layui/layui.js" charset="utf-8"></script>
	<script type="text/javascript" src="/static/admin/js/xadmin.js"></script>
</head>
<body>
<div class="x-nav">
      <span class="layui-breadcrumb">
        <a href="">首页</a>
        <a href="">演示</a>
        <a>
          <cite>导航元素</cite></a>
      </span>
	<a class="layui-btn layui-btn-small" style="line-height:1.6em;margin-top:3px;float:right" href="javascript:location.replace(location.href);" title="刷新">
		<i class="layui-icon" style="line-height:30px">ဂ</i></a>
</div>
<div class="x-body">
	<xblock>
		<button class="layui-btn layui-btn-danger" onclick="delAll()"><i class="layui-icon"></i>批量删除</button>
		<button class="layui-btn" onclick="x_admin_show('添加用户','./role-add.html')"><i class="layui-icon"></i>添加</button>
		<span class="x-right" style="line-height:40px">共有数据：<?php echo $authRole->total(); ?> 条</span>
	</xblock>
	<table class="layui-table">
		<thead>
		<tr>
			<th>
				<div class="layui-unselect header layui-form-checkbox" lay-skin="primary"><i class="layui-icon">&#xe605;</i></div>
			</th>
			<th>ID</th>
			<th>角色名</th>
			<th>描述</th>
			<th>状态</th>
			<th>操作</th>
		</thead>
		<tbody>
		<?php if(is_array($authRole) || $authRole instanceof \think\Collection || $authRole instanceof \think\Paginator): $i = 0; $__LIST__ = $authRole;if( count($__LIST__)==0 ) : echo "" ;else: foreach($__LIST__ as $key=>$row): $mod = ($i % 2 );++$i;?>
		<tr>
			<td>
				<div class="layui-unselect layui-form-checkbox" lay-skin="primary" data-id='<?php echo $row['role_id']; ?>'><i class="layui-icon">&#xe605;</i></div>
			</td>
			<td><?php echo $row['role_id']; ?></td>
			<td><?php echo $row['role_name']; ?></td>
			<td><?php echo $row['role_sign']; ?></td>
			<td class="td-status">
				<?php if($row['role_name']=="超级管理员"): else: if($row['role_status']==0): ?>
					<span class="layui-btn layui-btn-normal  layui-btn-sm  layui-btn-warm " >已启用</span>
					<?php else: ?>
					<span class="layui-btn layui-btn-normal  layui-btn-sm  layui-btn-warm layui-btn-disabled" >已停用</span>
					<?php endif; endif; ?>
			</td>
			<?php if($row['role_name']=="超级管理员"): else: ?>
			<td class="td-manage">
				<a onclick="member_stop(this,'<?php echo $row['role_id']; ?>')" href="javascript:;" title="<?php echo $row['role_status']=='1'?'启用' :'停用'; ?>">
					<i class="layui-icon">&#xe601;</i>
				</a>
				<a title="编辑" onclick="x_admin_show('编辑','<?php echo url('admin/AdminRole/edit',['role_id'=>$row['role_id']]); ?>')" href="javascript:;">
					<i class="layui-icon">&#xe642;</i>
				</a>
				<a title="删除" onclick="member_del(this,'<?php echo $row['role_id']; ?>')" href="javascript:;">
					<i class="layui-icon">&#xe640;</i>
				</a>
			</td>
			<?php endif; ?>
		</tr>
		<?php endforeach; endif; else: echo "" ;endif; ?>
		</tbody>
	</table>
	<div class="page">
		<?php echo $authRole->render(); ?>
	</div>
</div>
<script>
    /*用户-停用*/
    function member_stop(obj, id) {
        layer.confirm('确认要停用吗？', function (index) {
			$.post("<?php echo url('admin/AdminRole/adminStatus'); ?>", {role_id:id,role_status:obj.title}, function(res, textStatus, xhr) {
                if (res.code == 0) {
                    layer.msg(res.msg, function () {
                    });
                } else {
                    layer.alert(res.msg, function () {
                        location.reload();
                    })
                }
			});
        });
    }
    /*用户-删除*/
    function member_del(obj, id) {
        layer.confirm('确认要删除吗？', function (index) {
            //发异步删除数据
            $.post("<?php echo url('admin/AdminRole/del'); ?>", {role_id: id}, function (res, textStatus, xhr) {
                if (res.code == 0) {
                    layer.msg(res.msg, function () {
                    });
                } else {
                    layer.alert(res.msg, function () {
                        location.reload();
                    })
                }
            });
        });
    }
	/*删除所选用户*/
    function delAll(argument) {
        var data = tableCheck.getData();
        id = '';
        for (var i in data) {
            id += data[i] + ',';
        }
        layer.confirm('确认要删除吗？', function (index) {
            //捉到所有被选中的，发异步进行删除
            $.post("<?php echo url('admin/AdminRole/del'); ?>", {role_id: id}, function (res, textStatus, xhr) {
                if (res.code == 0) {
                    layer.msg(res.msg, function () {
                    });
                } else {
                    layer.alert(res.msg, function () {
                        location.reload();
                    })
                }
            });
        });
    }
</script>
</body>
